package com.tianqu.tms.entity;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

import com.tianqu.tms.core.exception.TmsDaoException;
import com.tianqu.tms.core.util.StringUtil;
import com.tianqu.tms.dao.CarPortCountDao;
import com.tianqu.tms.dao.TmsDao;
import com.tianqu.tms.dto.CarPortCountDto;

/**
 * @author zhangxueliang
 * 处理库存统计entity
 */
public class CarPortCount extends ViewListManager{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	
	private long id;
	//车牌号码
	private String carLicense;
	//入场时间
	private Timestamp inputTime;
	//商户id
	private int mId;
	//图片地址
	private String imgPath;
	//卡片号码
	private String cardId;
	//入口名称
	private String channelName;
	//处理时间
	private Timestamp acceptTime;
	
	
	//库存总数
	private int allUsedCarPort;
	//累计入库
	private int allInnerCar;
	//今日入库
	private int todayInner;
	//本月入库
	private int monthInner;
	//昨日入库
	private int yesterdayInner;
	//本周入库
	private int weekInner;
	//1季度入库
	private int seasonOneInner;
	//2季度入库
	private int seasonTwoInner;
	//3季度入库
	private int seasonThreeInner;
	//4季度入库
	private int seasonFourInner;
	//商户名称
	private String memName;
	//车位数
	private int carPort;
	//正在使用的车位数
	private int usedCarPort;
	
	//判断是否库存总数大于车位总数
	private int flag=1;//1:不大于，2：大于
	//样式
	private int style=1;//1：单行2：双行
	//列序号
	private int num=1;
	
	public static CarPortCount getInstance() {
		CarPortCount carPortCount = new CarPortCount();
		carPortCount.setExisting(false);
		return carPortCount;
	}
	
	/**
	 * 载入商户车辆统计列表
	 * @return
	 * @throws TmsDaoException
	 */
	public List<CarPortCountDto> loadCount() throws TmsDaoException{		
		CarPortCountDao carDao = (CarPortCountDao) TmsDao.getInstance(TmsDao.TMS_MEMBER_INVENTORY,
				getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		
		//给个当前年份的时间
		int yy=Integer.parseInt(new SimpleDateFormat("yyyy").format(Calendar.getInstance().getTime()));//年
		
		List<CarPortCountDto> list = carDao.loadCarPortCount(yy);
		List<CarPortCountDto> memList = new ArrayList<CarPortCountDto>();
		for(CarPortCountDto dto : list){
			Car car = Car.getInstance();
			int count = car.findCarCountByMem(1, dto.getMemId());
			dto.setUsedCarPort(String.valueOf(count));
			int carPort = 0;
			if(!StringUtil.isNullOrBlank(dto.getCarPort())){
				
				carPort = Integer.parseInt(dto.getCarPort());
			}
			if(carPort == 0){
				dto.setCarPort("-");
			}
			if( carPort < count)
			{
				dto.setWarnFlag(1);
			}else{
				dto.setWarnFlag(2);
			}
			
			memList.add(dto);
		}

		return memList;
	}
	

	public List<Integer> countCarInfo() throws TmsDaoException{
		CarPortCountDao carDao = (CarPortCountDao) TmsDao.getInstance(TmsDao.TMS_MEMBER_INVENTORY,
				getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		//
		return carDao.countCarInfo();
	}

	public List<CarPortCountDto> countCarInfoByFloor(int floor) throws TmsDaoException{
		CarPortCountDao carDao = (CarPortCountDao) TmsDao.getInstance(TmsDao.TMS_MEMBER_INVENTORY,
				getPageNo(), getMaxIndex(), getSortKey(), isAsc());
		//
		return carDao.countCarInfoByFloor(floor);
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getCarLicense() {
		return carLicense;
	}
	public void setCarLicense(String carLicense) {
		this.carLicense = carLicense;
	}
	public Timestamp getInputTime() {
		return inputTime;
	}
	public void setInputTime(Timestamp inputTime) {
		this.inputTime = inputTime;
	}
	public int getmId() {
		return mId;
	}
	public void setmId(int mId) {
		this.mId = mId;
	}
	public String getImgPath() {
		return imgPath;
	}
	public void setImgPath(String imgPath) {
		this.imgPath = imgPath;
	}
	public String getCardId() {
		return cardId;
	}
	public void setCardId(String cardId) {
		this.cardId = cardId;
	}
	public String getChannelName() {
		return channelName;
	}
	public void setChannelName(String channelName) {
		this.channelName = channelName;
	}
	public Timestamp getAcceptTime() {
		return acceptTime;
	}
	public void setAcceptTime(Timestamp acceptTime) {
		this.acceptTime = acceptTime;
	}
	public int getAllUsedCarPort() {
		return allUsedCarPort;
	}
	public void setAllUsedCarPort(int allUsedCarPort) {
		this.allUsedCarPort = allUsedCarPort;
	}
	public int getAllInnerCar() {
		return allInnerCar;
	}
	public void setAllInnerCar(int allInnerCar) {
		this.allInnerCar = allInnerCar;
	}
	public int getTodayInner() {
		return todayInner;
	}
	public void setTodayInner(int todayInner) {
		this.todayInner = todayInner;
	}
	public int getMonthInner() {
		return monthInner;
	}
	public void setMonthInner(int monthInner) {
		this.monthInner = monthInner;
	}
	public int getYesterdayInner() {
		return yesterdayInner;
	}
	public void setYesterdayInner(int yesterdayInner) {
		this.yesterdayInner = yesterdayInner;
	}
	public int getWeekInner() {
		return weekInner;
	}
	public void setWeekInner(int weekInner) {
		this.weekInner = weekInner;
	}
	public int getSeasonOneInner() {
		return seasonOneInner;
	}
	public void setSeasonOneInner(int seasonOneInner) {
		this.seasonOneInner = seasonOneInner;
	}
	
	public int getSeasonTwoInner() {
		return seasonTwoInner;
	}

	public void setSeasonTwoInner(int seasonTwoInner) {
		this.seasonTwoInner = seasonTwoInner;
	}

	public int getSeasonThreeInner() {
		return seasonThreeInner;
	}
	public void setSeasonThreeInner(int seasonThreeInner) {
		this.seasonThreeInner = seasonThreeInner;
	}
	public int getSeasonFourInner() {
		return seasonFourInner;
	}
	public void setSeasonFourInner(int seasonFourInner) {
		this.seasonFourInner = seasonFourInner;
	}
	public int getFlag() {
		return flag;
	}
	public void setFlag(int flag) {
		this.flag = flag;
	}

	public String getMemName() {
		return memName;
	}

	public void setMemName(String memName) {
		this.memName = memName;
	}

	public int getCarPort() {
		return carPort;
	}

	public void setCarPort(int carPort) {
		this.carPort = carPort;
	}

	public int getUsedCarPort() {
		return usedCarPort;
	}

	public void setUsedCarPort(int usedCarPort) {
		this.usedCarPort = usedCarPort;
	}

	public int getStyle() {
		return style;
	}

	public void setStyle(int style) {
		this.style = style;
	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

}
